home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / stk100.zip / STK.H < prev    next >
C/C++ Source or Header  |  1990-10-20  |  7KB  |  193 lines

  1. /**********************************************************************
  2. * stk.h
  3. * All prototypes and global typedefs for the sprite toolkit
  4. * concatenated into one include file. (The separate include 
  5. * files can be found from the stksrc archieve.)
  6. *
  7. * The files marked with S are selfcontained, and may be used
  8. * alone. The rest of the files need the definitions from the 
  9. * file spr.h. 
  10. *
  11. * "grtypes.h"    ** Misc type defs                      (S) **
  12. * "gr.h"         ** Graphics start, end, text I/O       (S) **
  13. * "mouse.h"      ** Mouse (INT 33) interface            (S) **
  14. * "spr.h"        ** Sprite init, create, display, erase (S) **
  15. * "spr_hit.h"    ** Sprite collision detection              **
  16. * "spr_fio.h"    ** Sprite file I/O                         **
  17. * "spr_anim.h"   ** Automatic spr animation & movement      **
  18. **********************************************************************
  19.                     This file is part of
  20.  
  21.           STK -- The sprite toolkit -- version 1.0
  22.  
  23.               Copyright (C) Jari Karjala 1990
  24.  
  25. The sprite toolkit (STK) is a FreeWare toolkit for creating high
  26. resolution sprite graphics with PCompatible hardware. This toolkit 
  27. is provided as is without any warranty or such thing. See the file
  28. COPYING for further information.
  29.  
  30. **********************************************************************
  31. **********************************************************************/
  32.  
  33.  
  34. #if     !defined(__GRTYPES_H_)
  35. #define __GRTYPES_H_
  36. #ifndef NULL
  37. #define NULL ((void*)0)
  38. #endif
  39. typedef unsigned char BYTE;
  40. typedef unsigned int  WORD;
  41. typedef BYTE *BITMAP;
  42. #endif
  43. #if     !defined(__GR_H_)
  44. #define __GR_H_
  45. #define GR_TYPE_ANY 0   /* Any mode will do */
  46. #define GR_TYPE_SPR 1   /* The best possible mode for the sprite toolkit */
  47. void gr_detect(int type, int *graphdriver, int *graphmode);
  48. void gr_start(int *graphdriver, int *graphmode);
  49. void gr_end(void);
  50. void gr_putch(char ch);
  51. void gr_puts(char *s);
  52. void gr_printf(char *s,...);
  53. #define gr_gotoxy(x, y) moveto(x*8, y*8)
  54. void gr_xy_printf(int x, int y, char *s,...);
  55. void gr_dual_xy_printf(int x, int y, char *s,...);
  56. int gr_inkey(void);
  57. char *gr_gets(char *cpdest, int max_len);
  58. extern int gr_max_x;
  59. extern int gr_max_y;
  60. extern int gr_text_mode;
  61. #define GR_MODE_OR      (1<<0)      /* OR the text over previous graphics */
  62. #define GR_MODE_CLEAR   (1<<1)      /* Clear the backgroud before print  */
  63. extern char gr_keys[128];
  64. void gr_start_kbd_grab(void);
  65. void gr_end_kbd_grab(void);
  66. #define GR_KEY_ESC  1
  67. #define GR_KEY_1    2
  68. #define GR_KEY_2    3
  69. #define GR_KEY_3    4
  70. #define GR_KEY_4    5
  71. #define GR_KEY_5    6
  72. #define GR_KEY_6    7
  73. #define GR_KEY_7    8
  74. #define GR_KEY_8    9
  75. #define GR_KEY_9    10
  76. #define GR_KEY_0    11
  77. #define GR_KEY_TAB  15
  78. #define GR_KEY_Q    16
  79. #define GR_KEY_W    17
  80. #define GR_KEY_E    18
  81. #define GR_KEY_R    19 
  82. #define GR_KEY_T    20
  83. #define GR_KEY_Y    21
  84. #define GR_KEY_U    22
  85. #define GR_KEY_I    23
  86. #define GR_KEY_O    24
  87. #define GR_KEY_P    25
  88. #define GR_KEY_A    30
  89. #define GR_KEY_S    31
  90. #define GR_KEY_D    32
  91. #define GR_KEY_F    33
  92. #define GR_KEY_G    34
  93. #define GR_KEY_H    35
  94. #define GR_KEY_J    36
  95. #define GR_KEY_K    37
  96. #define GR_KEY_L    38
  97. #define GR_KEY_Z    44
  98. #define GR_KEY_X    45 
  99. #define GR_KEY_C    46
  100. #define GR_KEY_V    47
  101. #define GR_KEY_B    48
  102. #define GR_KEY_N    49
  103. #define GR_KEY_M    50
  104. #define GR_KEY_COMMA    51
  105. #define GR_KEY_DOT      52
  106. #define GR_KEY_SPACE    57
  107. #define GR_KEY_ARROW_UP     72
  108. #define GR_KEY_ARROW_DOWN   80
  109. #define GR_KEY_ARROW_LEFT   75
  110. #define GR_KEY_ARROW_RIGHT  77
  111. #endif
  112. #if     !defined(__MOUSE_H_)
  113. #define __MOUSE_H_
  114. int     mouse_initialize(void);
  115. #endif
  116. #ifndef __SPR_H_
  117. #define __SPR_H_
  118. extern int spr_pass_delay;
  119. #define spr_max_x gr_max_x
  120. #define spr_max_y gr_max_y
  121. #ifndef __SPRITE_
  122. typedef void *SPRITE;
  123. #endif
  124. void spr_initialize(int graphicsdriver);
  125. SPRITE spr_create(WORD w, WORD h, 
  126.                   BITMAP pic, BITMAP mask, 
  127.                   BYTE res, WORD ID);
  128. SPRITE spr_share(SPRITE spr, BYTE n);
  129. SPRITE spr_copy(SPRITE spr, WORD id);
  130. void spr_put(SPRITE spr, WORD x, WORD y);
  131. void spr_hide(SPRITE spr);
  132. void spr_delete(SPRITE spr);
  133. WORD spr_next_pass(void);
  134. void spr_regulate_speed(void);
  135. WORD spr_get_id(SPRITE spr);
  136. WORD spr_get_x(SPRITE spr);
  137. WORD spr_get_y(SPRITE spr);
  138. WORD spr_get_width(SPRITE spr);
  139. WORD spr_get_height(SPRITE spr);
  140. #endif
  141. #ifndef __SPR_HIT_H_
  142. #define __SPR_HIT_H_
  143. int spr_hit_with_point(SPRITE spr, WORD x, WORD y);
  144. int spr_hit(SPRITE spr1, SPRITE spr2);
  145. SPRITE spr_hit_first(SPRITE spr);
  146. SPRITE spr_hit_next(SPRITE spr);
  147. #endif
  148. #ifndef __SPR_FIO_H_
  149. #define __SPR_FIO_H_
  150. SPRITE spr_fio_read_smp(char *smpfile, BYTE res, WORD ID);
  151. #endif
  152. #ifndef __SPR_ANIM_H_
  153. #define __SPR_ANIM_H_
  154. #ifndef __ANIM_SPRITE_
  155. typedef void *ANIM_SPRITE;
  156. #endif
  157. typedef struct _anim_spr_info {
  158.     int     x,y;                            /** location        **/
  159.     int     dx,dy;                          /** movement vector **/
  160.     int     lef, top, rig, bot;             /** limits          **/
  161.     WORD    frame, frame_delay, timeout;    /** time info       **/
  162.     WORD    id;     /** the user spesified id of current sprite **/
  163.     int     w,h;                            /** width&height    **/
  164. } ANIM_SPR_INFO;
  165. #define SPR_ANIM_FX_ALL       (0xFFFF) /** all fx       **/
  166. #define SPR_ANIM_FX_TIMEOUT     (1<<0) /** timeout      **/
  167. #define SPR_ANIM_FX_HIT_X_LIMIT (1<<1) /** hit x limit  **/
  168. #define SPR_ANIM_FX_HIT_Y_LIMIT (1<<2) /** hit y limit  **/
  169. #define SPR_ANIM_FX_HIT_SPRITE  (1<<3) /** hit other spr**/
  170. #define SPR_ANIM_FX_RET_NOTHING (0)     /** continue normally       **/
  171. #define SPR_ANIM_FX_RET_RE_PUT  (1)     /** put the sprite again    **/
  172. #define SPR_ANIM_FX_RET_STOP    (2)     /** stop the animation      **/
  173. #define SPR_ANIM_FX_RET_DELETE  (3)     /** delete the anim.sprite  **/
  174. #define SPR_ANIM_FX_RET_DESTROY (4)     /** destroy the anim.sprite **/
  175. ANIM_SPRITE spr_anim_create(WORD count, ...);
  176. void spr_anim_start(ANIM_SPRITE aspr);
  177. void spr_anim_stop(ANIM_SPRITE aspr);
  178. void spr_anim_delete(ANIM_SPRITE aspr);
  179. void spr_anim_destroy(ANIM_SPRITE aspr);
  180. WORD spr_anim_next_pass(void);
  181. ANIM_SPR_INFO *spr_anim_get_info(ANIM_SPRITE aspr);
  182. void spr_anim_set_location(ANIM_SPRITE aspr, WORD x, WORD y);
  183. void spr_anim_set_vector(ANIM_SPRITE aspr, int dx, int dy);
  184. void spr_anim_set_limits(ANIM_SPRITE aspr,
  185.                          WORD lef, WORD top, WORD rig, WORD bot);
  186. void spr_anim_set_time(ANIM_SPRITE aspr,
  187.                        int frame, int frame_delay, int timeout);
  188. void spr_anim_set_fx_handler(ANIM_SPRITE aspr, 
  189.                              WORD fx_mask, 
  190.                              WORD (fx_handler)(ANIM_SPRITE,WORD,SPRITE));
  191. #endif
  192.